//
//  HZZPersonalCenterViewController.m
//  HZZ_Sb
//
//  Created by 郭晓东 on 2018/2/8.
//  Copyright © 2018年 Hzz. All rights reserved.
//

#import "HZZPersonalCenterViewController.h"
#import "UIViewController+MMDrawerController.h"


@interface HZZPersonalCenterViewController ()<UICollectionViewDelegate ,UICollectionViewDataSource>


@property (nonatomic ,strong) UICollectionView *collectionView;

@property (nonatomic ,strong) NSMutableArray *dataArray;

@property (nonatomic ,strong) UIView *bottomBar;

@end

@implementation HZZPersonalCenterViewController

static NSString *const itemStr = @"itemStr";

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.view addSubview:self.collectionView];
    
    [self.view addSubview:self.bottomBar];

}

#pragma mark 定义展示的UICollectionViewCell的个数
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 10;
}

#pragma mark 定义展示的Section的个数
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 1;
}

#pragma mark 每个UICollectionView展示的内容
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:itemStr forIndexPath:indexPath];
    cell.contentView.backgroundColor = [UIColor redColor];
    return cell;
}

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    UIViewController *vc = [[UIViewController alloc] init];
    vc.view.backgroundColor = [UIColor redColor];
    vc.title = @"二级界面";
    [self.navigationController pushViewController:vc animated:NO];
    __weak typeof(self) weakSelf = self;
//    [self.mm_drawerController closeDrawerAnimated:NO completion:^(BOOL finished) {
//        //设置打开抽屉模式为MMOpenDrawerGestureModeNone，也就是没有任何效果。
//        [weakSelf.mm_drawerController setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeNone];
//    }];

}

-(UICollectionView *)collectionView{
    
    if (!_collectionView) {
        //背景颜色
        UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
        //定义每个UICollectionView 横向的间距
        flowLayout.minimumLineSpacing = 5;
        //定义每个UICollectionView 纵向的间距
        flowLayout.minimumInteritemSpacing = 5;
        //定义每个UICollectionView 的边距距
        flowLayout.sectionInset = UIEdgeInsetsMake(0, 10, 0, 10);
        flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
        
        _collectionView = [[UICollectionView alloc] initWithFrame:(CGRect){self.view.bounds.origin,self.view.bounds.size.width,self.view.bounds.size.height - TabbarH} collectionViewLayout:flowLayout];
        _collectionView.backgroundColor = UIColorFromHex(0xF5F5F5);
        //设置代理
        _collectionView.delegate = self;
        _collectionView.dataSource = self;
        _collectionView.showsHorizontalScrollIndicator = NO;
//        _collectionView.pagingEnabled = YES;
        [_collectionView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];

        [_collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:itemStr];
    }
    return _collectionView;
}

-(UIView *)bottomBar
{
    if (!_bottomBar) {
        _bottomBar = [[UIView alloc] initWithFrame:CGRectMake(0, SCREEN_H - TabbarH, 200, TabbarH)];
        _bottomBar.backgroundColor = [UIColor yellowColor];
        
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        button.frame = CGRectMake(0, 0, 200, 49);
        button.titleLabel.font = fontWithPingfang(15);
        [button setTitle:@"个人中心" forState:UIControlStateNormal];
        [button setTitleColor:UIColorHex(0x010101) forState:UIControlStateNormal];
        [_bottomBar addSubview:button];
    }
    return _bottomBar;
}

@end
